package com.sojson.base.impl;

import com.sojson.config.exception.TransErrorCode;
import com.sojson.config.exception.TransException;
import com.sojson.result.Result;
import com.sojson.util.page.PageUtil;

/**
 * 基础Controller
 * 
 * @author liu
 * @date 2020-11-02
 */
public class BaseController<T> {

    /** 设置请求分页数据(默认有分页)  */
    protected void startPage() {
        PageUtil.startPage();
    }

    /** 设置请求分页数据(默认查所有) */
    protected void startPageAll() {
        PageUtil.startPageAll();
    }

    /** 设置请求分页数据(默认有分页,默认按ID降序排序)  */
    protected void startPageDefaultSort(BaseDto baseDto) {
        PageUtil.startPageDefaultSort();
    }

    /** 设置请求分页数据(默认查所有,默认按ID降序排序) */
    protected void startPageAllDefaultSort(BaseDto baseDto) {
        PageUtil.startPageAllDefaultSort();
    }

    public static <T> Result<T> success() {
        return Result.success();
    }

    public static <T> Result<T> successMeg(String message) {
        return Result.successMeg(message);
    }

    public static <T> Result<T> success(String message, T data) {
        return Result.success(message, data);
    }

    public static <T> Result<T> success(String message, T data, Object other) {
        return Result.success(message, data, other);
    }

    public static <T> Result<T> success(Integer code, String message, T data, Object other) {
        return Result.success(code, message, data, other);
    }

    public static <T> Result<T> success(TransException transException, T data, Object other) {
        return Result.success(transException, data, other);
    }

    public static <T> Result<T> success(T data) {
        return Result.success(data);
    }

    public static <T> Result<T> success(T data, Object other) {
        return Result.success(data, other);
    }

    public static <T> Result<T> success(TransErrorCode transErrorCode, T data, Object other) {
        return Result.success(transErrorCode, data, other);
    }

    public static <T> Result<T> fail() {
        return Result.fail();
    }

    public static <T> Result<T> fail(String message) {
        return Result.fail(message);
    }

    public static <T> Result<T> fail(Integer code, String message) {
        return Result.fail(code, message);
    }

    public static <T> Result<T> fail(Integer code, String message, T data) {
        return Result.fail(code, message, data);
    }

    public static <T> Result<T> fail(Integer code, String message, T data, Object other) {
        return Result.fail(code, message, data, other);
    }

    public static <T> Result<T> fail(TransException transException) {
        return Result.fail(transException);
    }

    public static <T> Result<T> fail(TransException transException, T data) {
        return Result.fail(transException, data);
    }

    public static <T> Result<T> fail(TransException transException, T data, Object other) {
        return Result.fail(transException, data, other);
    }

    public static <T> Result<T> fail(TransErrorCode transErrorCode) {
        return Result.fail(transErrorCode);
    }

    public static <T> Result<T> fail(TransErrorCode transErrorCode, T data) {
        return Result.fail(transErrorCode, data);
    }

    public static <T> Result<T> fail(TransErrorCode transErrorCode, T data, Object other) {
        return Result.fail(transErrorCode, data, other);
    }

}